<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition template="../templates/mainTemplate.xhtml">
	<f:metadata>
		<f:event type="preRenderView" listener="#{userDetailsBean.init}" />
	</f:metadata>

	<ui:define name="content">
		<div class="toolbar">
			<h:form id="user-details-toolbar">
				<p:toolbar>
					<p:toolbarGroup align="left">
						<p:commandButton id="blockButton"
							action="#{userDetailsBean.blockUser}"
							rendered="#{userDetailsBean.user.active}" process="@none"
							update="user-details-toolbar user-details-form"
							value="#{msg['userdetails.block']}" image="ui-icon-locked" />
						<p:commandButton id="unblockUser"
							action="#{userDetailsBean.unblockUser}"
							rendered="#{not userDetailsBean.user.active}" process="@none"
							update="user-details-toolbar user-details-form"
							value="#{msg['userdetails.unblock']}" image="ui-icon-unlocked" />

						<p:button value="#{msg['userdetails.userList']}"
							outcome="pretty:userList" image="ui-icon-folder-open" />

						<p:separator />

					</p:toolbarGroup>
					<p:toolbarGroup align="right">

						<p:commandButton type="button"
							value="#{msg['userdetails.delete']}"
							onclick="confirmation.show()" image="ui-icon-trash" />

					</p:toolbarGroup>
				</p:toolbar>

				<p:confirmDialog message="#{msg['userdetails.confirmDialogText']}"
					header="#{userDetailsBean.login}" severity="alert"
					widgetVar="confirmation">
					<p:commandButton action="#{userDetailsBean.removeUser}"
						ajax="false" value="#{msg['userdetails.buttonYes']}"
						oncomplete="confirmation.hide()" />
					<p:commandButton type="button" onclick="confirmation.hide()"
						value="#{msg['userdetails.buttonNo']}" />
				</p:confirmDialog>

			</h:form>
		</div>

		<div class="box">
			<h2>
				<a href="#" id="toggle-user-details"> <h:outputFormat
						value="#{msg['userdetails.edit']}">
						<f:param value="#{userDetailsBean.login}" />
					</h:outputFormat>
				</a>
			</h2>
			<div class="block accordion" id="user-details">
				<fieldset>
					<legend>
						<h:outputText value="#{msg['userdetails.userdata']}" />
					</legend>
					<h:form id="user-details-form">
						<p:message for="saveButton" showSummary="false" />
						<p:message for="username" showSummary="false" />
						
						<p>
							<label><h:outputText
									value="#{msg['loginLogoutMenu.email']}" /></label>
							<p:inputText id="username" required="true"
								value="#{userDetailsBean.login}"
								label="#{msg['loginLogoutMenu.email1']}" />
						</p>

						<p:message for="password1" showSummary="false" />
						<p>
							<label><h:outputText
									value="#{msg['loginLogoutMenu.pass']}" /></label>
							<p:inputText id="password1" value="#{userDetailsBean.pass1}"
								type="password" required="true"
								label="#{msg['loginLogoutMenu.password1']}" />
						</p>

						<p:message for="password2" showSummary="false" />
						<p>
							<label><h:outputText
									value="#{msg['loginLogoutMenu.repass']}" /></label>
							<p:inputText id="password2" value="#{userDetailsBean.pass2}"
								type="password" required="true"
								label="#{msg['loginLogoutMenu.password1']}" />
						</p>

						<p:commandButton id="saveButton"
							action="#{userDetailsBean.saveDetails}"
							binding="#{userDetailsBean.button}" process="@form"
							update="@form" value="#{msg['userdetails.saveButton']}" />
					</h:form>
				</fieldset>
			</div>
		</div>
	</ui:define>
</ui:composition>

</html>
